/*
 * Filtro.java
 * Copyright (C) 04/01/2006, 23:46 Francisco J. Hernández
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 */

package Sindarin;

import java.io.File;

import javax.swing.filechooser.FileFilter;
class Filtro extends FileFilter {
    String ext;
    String des;
    
    // Accept all directories and all gif, jpg, or tiff files.
    public boolean accept(File f) {

        if (f.isDirectory())
            return true;

        String s = f.getName();
        int i = s.lastIndexOf('.');
        
        if (i > 0 &&  i < s.length() - 1) {
            String extension = s.substring(i+1).toLowerCase();
            if (ext.equals(extension))
                    return true;
        }

        return false;
    }
    
   public String getDescription() {
       return des;
   }

    private static final String SINDESC = java.util.ResourceBundle.getBundle("Sindarin/config").getString("TEXT_NON_DESCRIPTION");

    public Filtro(String nExt) {
        ext = nExt;
        des = SINDESC;
    }

    public Filtro(String nExt, String nDes) {
        ext = nExt;
        des = nDes;
    }
}
